﻿using ATM.BUS;
using ATM.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ATMSystem
{
    public partial class frmInsertPIN : Form
    {
        private Account passData_Account;
        private Card passData_Card;
        private static int count = 0;
        private frmModel frm1;

        public frmInsertPIN()
        {
            InitializeComponent();
        }

        public frmInsertPIN(Account acc, Card card)
        {
            InitializeComponent();
            passData_Account = acc;
            passData_Card = card;
            txtWelcome.Text = "Welcome, " + ValidationBUS.GetCusName(passData_Account);
        }
        
        private void btnOK_Click(object sender, EventArgs e)
        {
            Console.WriteLine(ValidationBUS.Authentication(passData_Card, txtPassword.Text, count));
            switch (ValidationBUS.Authentication(passData_Card, txtPassword.Text, count++))
            {
                case 0:
                    frm1 = new frmModel(passData_Account,passData_Card);
                    frm1.ShowDialog();
                    break;
                case 2:
                    txtWarning.Text = "YOUR CARD IS BLOCKED !";
                    break;
                case 1:
                    txtWarning.Text = "WRONG PASSWORD ! RERTY !";
                    break;
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
